﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using webnew.Common;
namespace webnew.Systems
{
    public partial class S_SystemTypeList : ListBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            _EditSrc = "S_SystemTypeEdit.aspx";
            _DelType = DeleteType.FalseDel;//逻辑删除
            _Grdview = grdView;//主列表控件
            btnExcelVisble = false; //设置导出不可见
            #region 传递参数，把控件值赋值给参数
            _SrcPrams = "&SystemType=" + ddlSystemType.SelectedValue;
            _SrcPrams += "&RecordCount=" + AspNetPager1.RecordCount + "&CurrentPageIndex=" + AspNetPager1.CurrentPageIndex;
            #endregion
            if (!IsPostBack)
            {
                SetTitle(true, "后台管理 >> 类别管理");
                CommonHelper.DataDdlBind(ddlSystemType, new BLL.Sys_SystemType().GetSystemTypeList(), "SystemType", "SystemType");
                ddlSystemType.Items.Insert(0, new ListItem("--请选择--",Guid.Empty.ToString()));
                #region 接收参数，并赋值给检索控件
                if (Request.QueryString["SystemType"] != null) ddlSystemType.SelectedValue = Request.QueryString["SystemType"].ToString();
                //记录分页页数 需传递总条数和当前页数 
                if (Request.QueryString["RecordCount"] != null) AspNetPager1.RecordCount = Convert.ToInt32(Request.QueryString["RecordCount"]);
                if (Request.QueryString["CurrentPageIndex"] != null) AspNetPager1.CurrentPageIndex = Convert.ToInt32(Request.QueryString["CurrentPageIndex"]);
                #endregion
                AspNetPager1_PageChanged(null, null);
            }
        }

        /// <summary>
        /// 重写删除事件,使删除后刷新页面;
        /// </summary>
        protected override void _Del()
        {
            new BLL.Sys_SystemType().del(GetSelecetedIDs(grdView));
            AspNetPager1_PageChanged(null, null);
        }


        protected void btnSearch_Click(object sender, EventArgs e)
        {
            AspNetPager1_PageChanged(null, null);
        }

        /// <summary>
        /// 查询分页事件
        /// </summary>
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            System.Text.StringBuilder _conditon = new System.Text.StringBuilder();  //分页的查询的条件 
            _conditon.Append("isdel=0 ");
            if(ddlSystemType.SelectedValue!= Guid.Empty.ToString()) _conditon.Append("and SystemType ='" + ddlSystemType.SelectedValue + "' ");
            AspNetPager1.RecordCount = new BLL.Sys_SystemType().GetCount("sys_SystemType", _conditon.ToString());
            grdView.DataSource = new BLL.Sys_SystemType().GetPageList("*", _conditon.ToString(), grdView.PageSize, AspNetPager1.CurrentPageIndex, "sys_SystemType", "SystemType,sort,TypeName,id", true);
            grdView.DataBind();
        }

     

        protected void grdView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //鼠标经过变色
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "GridViewMouseover(this)");
                e.Row.Attributes.Add("onmouseout", "GridViewMouseout(this)");
                e.Row.Attributes.Add("onclick", "GridViewonclick(this)");
            }
        }
    }
}
